<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>生产计划</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
 
<link rel="stylesheet" href="../../res/css/button/button.css">
  <link rel="stylesheet" href="../../res/css/row/row.css">
  <link rel="stylesheet" href="../../res/layuis/css/layui.css">
   <link rel="stylesheet" href="../../res/layuis/css/modules/laydate/default/laydate.css">
  <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
  <script type="text/javascript" src="../../res/layuis/lay/modules/laydate.js" charset="utf-8"></script>
  <script type="text/javascript" src="../../res/layuis/layui.js" charset="utf-8"></script>
</head>
<body>
	 
	<div class="row" style="margin-top: 40px;">
		
		  <div class="layui-input-inline">
		<label class="layui-form-label"  >开始日期:</label>
			<input type="text"  class="layui-input" id="startTime" style="width: 224px;height: 38px;" required lay-verify="required">
		</div>
		
		<div class="layui-input-inline">
		<label class="layui-form-label"  >结束日期:</label>
			<input type="text"  class="layui-input" id="endTime" style="width: 224px;height: 38px;" required lay-verify="required">
		</div>
		
		 <div class="layui-input-inline">
         <input type="button" class="layui-btn" lay-submit lay-filter="formEdit" value="加入计划">
      </div>
	</div>
	
	<table class="layui-table" id="productionMusical">
	 <thead>
	    <tr>
	      <th lay-data="{align:'center'}" style="display: none;">乐器ID</th>
	      <th lay-data="{align:'center'}">乐器名称</th>
	      <th lay-data="{align:'center'}">乐器数量</th>
	      <th lay-data="{align:'center'}" style='text-align:center;'>操作</th>
	    </tr>
	 </thead>
	 <tbody id="productionMusicalTbody">
	 
	 </tbody>
</table>
<script type="text/javascript">
	
	$(function(){
		$.ajaxSetup({
			async: false
		});
		$("#musicalText").val("");
		$("#production").val("");
		 $("#addOrUpdate").val("");
		 $.ajaxSetup({
				async: true
		});
		console.info(getParameter("prodId"))
		prodId=getParameter("prodId");
		prodPermit=getParameter("prodPermit");
		manufactureType=getParameter("manufactureType");
		addOrUpdate=getParameter("addOrUpdate")
		
		 
		
		$("#production").val(prodId+","+prodPermit+","+manufactureType);
		$("#addOrUpdate").val(addOrUpdate);
		
		if(prodId){
			var url="../../listenProduction/findByProdId.action"
			var data={"prodId":prodId}
			$.post(url,data,function(mes){
				 $("#startTime").val(mes.prodStartTime)
				 $("#endTime").val(mes.prodEndTime)
			},"json") 
				
				
			var url="../../listenProductionDetail/findProductionDetail.action"
			var data={"prodId":prodId}
			$.post(url,data,function(mes){
				 $.each(mes.data,function(i,item){
					 $("#musicalText").val($("#musicalText").val()+item.muId+","+item.muName+","+item.pdNumber+"#")
				 })
			},"json") 
		}
		
		 
		
		
		 
	var musicalTexts = new Array()
	 var musicalTexts=$("#musicalText").val().split("#");
	 $("#productionMusicalTbody").html("")
	  musicalTexts=$("#musicalText").val().split("#");
	  for (var i = 0; i < musicalTexts.length; i++) {
		  if(musicalTexts[i]){
			  $("#productionMusicalTbody").append("<tr>"+
						"<td style='display:none;'>"+musicalTexts[i].split(",")[0]+"</td>" +
						"<td>"+musicalTexts[i].split(",")[1]+"</td>" +
						"<td><input type='text' name='title' id='number_"+musicalTexts[i].split(",")[0]+"' required lay-verify='required' value='"+musicalTexts[i].split(",")[2]+"' autocomplete='off' class='layui-input' style='border:0px;' onkeyup='input(this,event)'></td>" +
						"<td style='text-align:center;'><a class='layui-btn layui-btn-danger layui-btn-xs' lay-event='del'>删除</a></td>" +
						"</tr>")
					load();
		  }
	  }
		/**
		 * 从地址栏传值的代码
		 * @param param
		 * @returns
		 */

		function getParameter(param){
			var query = window.location.search;
			var iLen = param.length;
			var iStart = query.indexOf(param);
			if (iStart == -1)
				return "";
			iStart += iLen + 1;
			var iEnd = query.indexOf("&", iStart);
			if (iEnd == -1)
				return query.substring(iStart);
			return query.substring(iStart, iEnd);
		}
	})
 
	 
</script>
<input type="hidden" id="addOrUpdate" style="width: 100%;height: 50px;">
<input type="hidden" id="production" style="width: 100%;height: 50px;">
<input type="hidden" id="musicalText" style="width: 100%;height: 50px;">
<div id="checkedDiv" style="width: 15%;height: 526px;border: 1px solid #D3D3D3;box-shadow: 0 0 10px #C0C0C0;float: left;margin-top: 10px;margin-right: 10px;">
     
</div>

<div class="demoTable" style="margin-top: 10px;width: 75%;float: left;">
 	
    <div class="x-body">
     <div class="layui-input-inline">
    <form class="layui-form" >
    
      <div class="layui-input-inline">
          <input type="text" name="muName" id="muName" placeholder="请输入乐器名称" autocomplete="off" class="layui-input" >
      </div>
      <div class="layui-input-inline"  style="width:224px;">
       
          <select name="mtId" lay-filter="aihao" id="mtId">
	       	<option value="">请选择乐器类型</option>
	      </select>
      </div>
      <div class="layui-input-inline">
           <input type="text" name="startPrice" id="startPrice" placeholder="最小价格" autocomplete="off" class="layui-input">
      </div>
       <div class="layui-input-inline">
       	——
       </div>
      <div class="layui-input-inline">
           <input type="text" name="endPrice" id="endPrice" placeholder="最高价格" autocomplete="off" class="layui-input" >
      </div>
      </form>
        </div>
       <div class="layui-input-inline">
         <button class="layui-btn" data-type="reload" lay-filter="sreach" id="musicalSreach"><i class="layui-icon">&#xe615;</i></button>
      </div>
      
    
    
<table class="layui-table" lay-filter="demo" id="musical">
	
</table>
<script type="text/javascript">
layui.use('table',function(){
	  var table = layui.table;
	  var form = layui.form;
	  setTimeout(() => {
		  table.render({
			    elem: '#musical'
			    	,page: true
			    ,url:'../../listenMusical/selectAll.action?sort=1'
			    ,cols: [[
			    	{type:'checkbox',sort: true}
			      ,{field:'muId'}
			      ,{field:'muName',title: '乐器名称'}
			      ,{field:'mtName',title: '乐器类型'}
			      ,{field:'muPic',title: '乐器图片',templet:'#imgTpl'}
			      ,{field:'muPrice',title: '乐器价格'}
			      ,{field:'muSpecifications',title: '乐器规格'}
			    ]],id: 'idTest',done: function (res, curr, count) {
		            $("[data-field='muId']").css('display','none');
		            $("#productionMusicalTbody").html("")
		            
		            $("#checkedDiv").html("")
		           
					 var musicalTexts = new Array()
					 var musicalTexts=$("#musicalText").val().split("#");
			       	 for (var i = 0; i < musicalTexts.length-1; i++) {
			       		 
			       		
			       
			       	  $("#productionMusicalTbody").append("<tr>"+
								"<td style='display:none;'>"+musicalTexts[i].split(",")[0]+"</td>" +
								"<td>"+musicalTexts[i].split(",")[1]+"</td>" +
								"<td><input type='text' name='title' id='number_"+musicalTexts[i].split(",")[0]+"' required lay-verify='required' value='"+musicalTexts[i].split(",")[2]+"' autocomplete='off' class='layui-input' style='border:0px;' onkeyup='input(this,event)'></td>" +
								"<td style='text-align:center;'><a class='layui-btn layui-btn-danger layui-btn-xs' lay-event='del'>删除</a></td>" +
								"</tr>")
			       				form.render();
			        
			       	 $("#checkedDiv").append("<div id='checkedDiv"+musicalTexts[i].split(",")[0]+"' class='flag note note--success new-item' onclick='removeChecked(\"checkedDiv"+musicalTexts[i].split(",")[0]+"\",\""+musicalTexts[i].split(",")[0]+"\")'>"+
								"<div class='flag__image note__icon'><i class='fa fa-check'></i></div>"+
								" <div class='flag__body note__text'>"+musicalTexts[i].split(",")[1]+"</div>"+
									"</div>")
			       		$('#musical').next().find('.layui-table-body tr').each(function(index,item){
			       			
			       			var ids=$(item).find('td[data-field="muId"]').text();
			       			if(musicalTexts[i].split(",")[0]==ids){
			       				var index=$(item).data('index');
			       	            var che = $('#musical').next().find('.layui-table-body tr[data-index="'+index+'"] input[name="layTableCheckbox"]')
			       	            che.prop("checked",true)
			       	           form.render();
			       			}
			       			
			       		});
			       	}
			       	 
			    }
			  });
	}, 1000);
	 
});


</script>
</div>
</div>
 
<script type="textml" id="imgTpl">
    		<img style="width:300px;height:20px;" onmouseover="getPathOver(this)" alt="暂无图片" onmouseout="getPathOut()" src="../../{{ d.muPic }}">
</script>
 
 
 
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script type="text/javascript" src="../../res/js/production/productionPlan.js"></script>
</body>
</html>